/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nx2.behaviors;

import nx2.utils.*;
import javaclient2.*;
import javaclient2.structures.blobfinder.*;


/**
 *
 * @author alejo
 */
public class NxPSDetectCenter extends NxBehavior{

    Position2DInterface pos;
    BlobfinderInterface bf;

    public NxPSDetectCenter(String name, BlobfinderInterface bf, Position2DInterface pos)
    {
        super(name);
        this.bf = bf;
        this.pos = pos;
    }

    public Vector2D value()
    {

        PlayerBlobfinderData bfData = bf.getData();
        PlayerBlobfinderBlob[] bfd = bfData.getBlobs();

        PlayerBlobfinderBlob bfd1 = bfd[0];

        //distance to image center:
        int x = bfd1.getX() - bfData.getWidth();


        //now calculate camera position angle
        float camAngle = pos.getData().getPos().getPa();

        Vector2D result = new Vector2D(x,0,Vector2D.MODE_XY);

        result = result.rotate((float)-Math.PI/2 + camAngle);

        return new Vector2D();
    }

}
